package com.discuz.post;

import java.lang.reflect.Field;

public class ReflectUtil {
	
	

	public static String toString(Object obj){
		Class<? extends Object> clazz = obj.getClass();
		Field[] fields = clazz.getDeclaredFields();
		StringBuffer strBuf = new StringBuffer();
		strBuf.append(clazz.getName());
		strBuf.append("(");
		for (int i = 0; i < fields.length; i++) {
			Field fd = fields[i];
			strBuf.append(fd.getName() + ":");
			try {
				strBuf.append(fd.get(obj));
			} catch (Exception e) {
				e.printStackTrace();
			}
			if (i != fields.length - 1)
				strBuf.append("\n");
		}

		strBuf.append(")");
		return strBuf.toString();
	}
}

